package easy;

import util.PrintUtils;

public class Solution_1365 {

    public int[] smallerNumbersThanCurrent(int[] nums) {
        int[] arr = new int[101];
        for (int num : nums) {
            arr[num]++;
        }
        int[] counts = new int[101];
        counts[0] = 0;
        for (int i = 1; i < counts.length; i++) {
            counts[i] = counts[i - 1] + arr[i - 1];
        }
        for (int i = 0; i < nums.length; i++) {
            nums[i] = counts[nums[i]];
        }
        return nums;
    }

    public static void main(String[] args) {
        Solution_1365 model = new Solution_1365();
        PrintUtils.arrayInt(model.smallerNumbersThanCurrent(new int[]{8, 1, 2, 2, 3}));
        PrintUtils.arrayInt(model.smallerNumbersThanCurrent(new int[]{6, 5, 4, 8}));
        PrintUtils.arrayInt(model.smallerNumbersThanCurrent(new int[]{7, 7, 7, 7}));
    }
}
